package com.example.springboot01.config;


import com.example.springboot01.interceptor.AuthorizationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 * @author developer
 * @since 2022-5-30
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizationInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/**/swagger-ui.html")
                .excludePathPatterns("/**/configuration/ui")
                .excludePathPatterns("/**/swagger-resources")
                .excludePathPatterns("/**/configuration/security")
                .excludePathPatterns("/**/v2/api-docs")
                .excludePathPatterns("/**/error")
                .excludePathPatterns("/**/webjars/**")
                .excludePathPatterns("/**/**/favicon.ico");
    }
}
